#!/usr/bin/python

#run as array job

import os,sys
in_file_name = sys.argv[1]
in_file = open(in_file_name, 'r')
array_number = sys.argv[2]

file = '#$ -S /bin/tcsh\n#$ -cwd\n#$ -V\n'

file_content = in_file.readlines()
in_file.close()
number_of_jobs = len(file_content)

start_file = open('start_rescue.bin', 'w')
start_file.write(file)
start_file.write('/homes/brenk/work/scripts/docking_scripts/rescue_database_chunks.py '+ in_file_name + ' ' + array_number + ' ' + '$SGE_TASK_ID')
start_file.close()

os.system('chmod 755 start_rescue.bin')
os.system('qsub -q 64bit-pri.q -t 1-' + str(number_of_jobs) + ' start_rescue.bin')
